import tensorflow as tf

hello = tf.constant('Hello,Tensorflow!')
sess = tf.Session()
print(sess.run(hello))
sess.close()

#with session程序结束后会自动关闭session，不用手动去写close（）
a = tf.constant(3)
b = tf.constant(4)
with tf.Session() as sess:
    print("相加：",sess.run(a+b))

#注入机制，将实参注入到相应的placeholder中，feed只在调用它方法内有效，方法结束feed消失
a = tf.placeholder(tf.int16)
b = tf.placeholder(tf.int16)
add = tf.add(a, b)
with tf.Session() as sess:
    print("相加：",sess.run(add, feed_dict={a: 3, b: 4}))

